﻿<div ng-controller="orderController">
    <div class="wrapper border-bottom white-bg page-heading">
        <div class="col-lg-pull-12">
            <ol class="breadcrumb">
                <li><a href="javascript:void(0)" ng-click="goBack()">{{breadcrumb}}订单</a></li>
                <li class="active">订单详情</li>
            </ol>
        </div>
    </div>
    <div class="form-horizontal">
        <div class="row">
            <div class="col-sm-5 order_detail">
                <div class="panel panel-default">
                    <div class="panel-heading">订单信息</div>
                    <div class="panel-body">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">订单号：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.order.order_no}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">订单类型：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{get_platform_text(model.order.platform)}}订单</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">支付方式：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.order.pay_info.pay_name}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">交易号：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.order.pay_info.pay_no}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">支付流水号：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.order.pay_info.transaction_no}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">买家联系方式：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">
                                    {{model.order.buyer != null ? model.order.buyer.mobile : model.order.shipping.phone}}
                                </p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">收货人信息：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">
                                    {{model.order.shipping.ship_to}} {{model.order.shipping.cell_phone}}
                                </p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">收货人所在地：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">
                                    {{model.order.shipping.region_name}}
                                </p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">收货地址：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">
                                    {{model.order.shipping.address}}
                                </p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">买家留言：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.order.remark}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">真实姓名：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">
                                    {{model.order.shipping.real_name}}
                                </p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">身份证号：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">
                                    {{model.order.shipping.id_card}}
                                </p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">推单失败原因：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static" style="color:red;">
                                    {{model.order.push_fail_msg}}
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-7">
                <div class="panel panel-default">
                    <div class="panel-heading">订单状态：{{get_order_status(model.order.status)}}</div>
                    <div class="panel-body">
                        <div class="form-group">
                            <!-- 国外物流-->
                            <div class="sl-item" ng-repeat="item in model.list">
                                <div class="sl-content">
                                    <div class="text-muted">{{item.logisticstime}}</div>
                                    <p>{{status_name(item.logisticsstatue)}}</p>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div ng-if="model.order.status==5">
                                {{model.order.close_reason}}
                            </div>
                            <div ng-if="model.order.status==2 && currentUser.user_id==model.order.merchant_id">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">选择快递物流：</label>
                                    <div class="col-sm-9">
                                        <ui-select ng-model="kdniao_selected" theme="bootstrap" on-select="kdniao_change($item, $model)">
                                            <ui-select-match placeholder="选择快递物流">{{$select.selected.text}}</ui-select-match>
                                            <ui-select-choices repeat="item in kdniao | propsFilter: {text: $select.search, value: $select.search}">
                                                <div ng-bind-html="item.text | highlight: $select.search"></div>
                                                <small>快递物流编号: {{item.value}}</small>
                                            </ui-select-choices>
                                        </ui-select>
                                    </div>
                                </div>
                                <br />
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">快递物流单号：</label>
                                    <div class="col-sm-9">
                                        <input type="text" name="ship_order_number" class="form-control input-sm" ng-model="model.ship_order_number">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-9 col-lg-offset-3">
                                        <button type="submit" ng-click="shipping()" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="保存中..." ng-disabled="psdisabled">
                                            <i class="fa fa-truck"></i> 发货
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div ng-if="model.order.status==3||model.order.status==4" class="order_detail">
                            <div class="form-group" ng-if="model.order.status==3">
                                <label class="col-sm-3 control-label">收货时间：</label>
                                <div class="col-sm-9">
                                    <p class="form-control-static">
                                        买家 <ui-countdown class="text-danger"></ui-countdown> 来确认收货,超时订单自动确认收货
                                    </p>
                                </div>
                            </div>
                            <div ng-if="!update_type">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">物流公司：</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">{{model.order.shipping.express_company_name}}</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">物流公司编号：</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">{{model.order.shipping.express_no}}</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">快递物流单号：</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">{{model.order.shipping.ship_order_number}}</p>
                                    </div>
                                </div>
                                <div class="form-group" ng-show="logistic_info">
                                    <label class="col-sm-3 control-label">快递跟踪：</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static" ng-if="logistic_info.success">
                                            {{logistic_info.state=="2"?"在途中":(logistic_info.state=="3"?"签收":"问题件")}}
                                            <span ng-if="logistic_info.reason">{{logistic_info.reason}}</span>
                                        </p>
                                        <div class="streamline b-l m-b" ng-if="logistic_info.success">
                                            <div class="sl-item" ng-repeat="trace in logistic_info.traces">
                                                <div class="sl-content">
                                                    <div class="text-muted">{{trace.accept_time}}</div>
                                                    <p>{{trace.accept_station}}</p>
                                                </div>
                                            </div>
                                        </div>
                                        <p class="form-control-static" ng-if="!logistic_info.success">没有此快递</p>
                                    </div>
                                </div>
                            </div>
                            <div ng-if="update_type">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">选择快递物流：</label>
                                    <div class="col-sm-9">
                                        <ui-select ng-model="kdniao_selected" theme="bootstrap" on-select="kdniao_change($item, $model)">
                                            <ui-select-match placeholder="选择快递物流">{{$select.selected.text}}</ui-select-match>
                                            <ui-select-choices repeat="item in kdniao | propsFilter: {text: $select.search, value: $select.search}">
                                                <div ng-bind-html="item.text | highlight: $select.search"></div>
                                                <small>快递物流编号: {{item.value}}</small>
                                            </ui-select-choices>
                                        </ui-select>
                                    </div>
                                </div>
                                <br />
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">快递物流单号：</label>
                                    <div class="col-sm-9">
                                        <input type="text" name="ship_order_number" class="form-control input-sm" ng-model="model.order.ship_order_number">
                                    </div>
                                </div>
                            </div>
                            <br />
                            <div class="form-group">
                                <div class="col-sm-9 col-lg-offset-3">
                                    <button type="submit" ng-click="update_shipping()" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="保存中..." ng-disabled="psdisabled" ng-if="update_type">
                                        <i class="fa fa-truck"></i> 保存
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div ng-if="model.order.shipping_type == 3">
                        <div ng-if="model.order.status==2">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">配送人：</label>
                                <div class="col-sm-9">
                                    <input type="text" name="shipping_name" class="form-control input-sm" ng-model="model.order.shipping_name">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">电话：</label>
                                <div class="col-sm-9">
                                    <input type="text" name="shipping_phone" class="form-control input-sm" ng-model="model.order.shipping_phone">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-9 col-lg-offset-3">
                                    <button type="submit" ng-click="send_shipping()" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="保存中..." ng-disabled="psdisabled">
                                        <i class="fa fa-truck"></i> 送货
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
    <div class="form-horizontal">
        <div class="row">
            <div ng-if="model.order.push_status == 3 || model.order.push_status == 1">
                <div class="col-sm-6">
                    <div class="panel panel-default">
                        <div class="panel-heading">修改订单号</div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">原始订单号</label>
                                <div class="col-sm-8">
                                    <input type="text" name="order_no" class="form-control input-sm" ng-model="model.order.order_no" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">新订单号</label>
                                <div class="col-sm-8">
                                    <input type="text" name="new_order_no" class="form-control input-sm" ng-model="model.order.new_order_no" />
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-9 col-lg-offset-3">
                                    <button type="submit" ng-click="save_order()" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="保存中..." ng-disabled="psdisabled">
                                        <i class="fa fa-truck"></i> 保存
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="panel panel-default">
                        <div class="panel-heading">修改收货人信息</div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">身份证号</label>
                                <div class="col-sm-8">
                                    <input type="text" name="id_card" class="form-control input-sm" ng-model="model.order.shipping.id_card" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">真实姓名</label>
                                <div class="col-sm-8">
                                    <input type="text" name="real_name" class="form-control input-sm" ng-model="model.order.shipping.real_name" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">所属地</label>
                                <div class="col-sm-8">
                                    <input type="text" name="region_name" class="form-control input-sm" ng-model="model.order.shipping.region_name" />
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-9 col-lg-offset-3">
                                    <button type="submit" ng-click="save_info()" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="保存中..." ng-disabled="psdisabled">
                                        <i class="fa fa-truck"></i> 保存
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">修改商品保质期</div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品SKU</label>
                                <div class="col-sm-6">
                                    <input type="text" name="sku" class="form-control input-sm" ng-model="goods.sku" />
                                </div>
                                <div class="col-sm-2">
                                    <button type="submit" ng-click="search_sku(goods.sku)" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="查询中..." ng-disabled="psdisabled">
                                        <i class="fa fa-truck"></i> 查询
                                    </button>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">保质期开始时间</label>
                                <div class="col-sm-8">
                                    <input type="text" name="real_name" class="form-control input-sm" ng-model="goods.start_time" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">保质期结束时间</label>
                                <div class="col-sm-8">
                                    <input type="text" name="region_name" class="form-control input-sm" ng-model="goods.end_time" />
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-9 col-lg-offset-3">
                                    <!--<button type="submit" ng-click="save_sku()" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="保存中..." ng-disabled="psdisabled">
                                        <i class="fa fa-truck"></i> 保存
                                    </button>-->
                                    <button type="submit" ng-click="push(model.order.order_no)" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="推送中..." ng-disabled="psdisabled">
                                        <i class="fa fa-truck"></i> 推送
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <table class="table table-bordered">
        <thead>
            <tr style="background-color:#f7f7f9;">
                <th>商品</th>
                <td>SKU</td>
                <th width="100">成本价</th>
                <th width="100">单价</th>
                <th width="100">数量</th>
                <th width="100">优惠</th>
                <th width="100">总价</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="(index,order_item) in model.order.order_items">
                <td ng-init="count=model.order.order_items.length">
                    <div class="media">
                        <div class="media-left">
                            <a href="{{siteImg+order_item.share_url}}" target="_blank">
                                <img class="media-object img-thumbnail" ng-src="{{order_item.thumbnails_url|thumbnail:64:64}}">
                            </a>
                        </div>
                        <div class="media-body">
                            <p class="media-heading">{{order_item.product_name}}</p>
                            <p>{{order_item.sku_name}}</p>
                            <span>{{order_item.user_remark}}</span>
                        </div>
                    </div>
                </td>
                <td>{{order_item.product.sku}}</td>
                <td style="color:red;">{{order_item.product.cost_price | currency:'￥'}}</td>
                <td>
                    {{order_item.unit_price > 0 || order_item.red_drill==0 ? (order_item.unit_price | currency:'￥') :""}}
                    {{order_item.unit_price > 0 && order_item.red_drill > 0 ? " + " : ""}}
                    {{order_item.red_drill > 0 ? order_item.red_drill +"红钻" : ""}}
                </td>
                <td>{{order_item.quantity}} 件</td>
                <td>
                    <span ng-if="order_item.singe_sale_type==1">限时打折：省{{order_item.singe_sale_value | currency:'￥'}}</span>
                    <span ng-if="order_item.singe_sale_type==2">限时抢购：省{{order_item.singe_sale_value | currency:'￥'}}</span>
                </td>
                <td width="100" rowspan="{{count}}" ng-if="index==0">
                    <p>
                        {{model.order.order_amount > 0 || model.order.red_drill == 0 ? (model.order.order_amount | currency:'￥') : ""}}
                        {{model.order.order_amount > 0 && model.order.red_drill > 0 ? " + " :""}}
                        {{model.order.red_drill > 0 ? model.order.red_drill +"红钻" : ""}}
                    </p>
                    <p ng-if="model.order.coupon_id">优惠券:{{model.coupon_amount | currency:'￥'}}</p>
                    <p ng-if="model.order.order_sale_amount>0">{{model.order.order_sale_name}}:{{model.order.order_amount | currency:'￥'}}</p>
                    <p ng-if="model.order.integral_discount>0">积分抵扣:{{model.order.integral_discount | currency:'￥'}}</p>
                    <p>{{model.order.freight==0?'包邮':'运费：'+(model.order.freight | currency:'￥')}}</p>
                </td>
            </tr>
        </tbody>
    </table>
    <div ng-if="model.order.push_status == 3 || model.order.push_status == 1">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>规格名称</th>
                    <th>价格</th>
                    <th>库存</th>
                    <th>有效期开始时间</th>
                    <th>有效期结束时间</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="(index,sku) in goods.skus">
                    <td>{{sku.sku_name}}</td>
                    <td>{{sku.price}}</td>
                    <td>{{sku.stock}}</td>
                    <td>{{sku.start_Exp_Date}}</td>
                    <td>{{sku.end_Exp_Date}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
